#ifndef MATH_MODEL_H
#define MATH_MODEL_H

#include <QString>
#include <QList>
#include "point3d.h"
#include "planet_math.h"
class AbstractSolver;

class BondsMatrix
{
private:

  
public:
  int length;
  double** bonds;

  BondsMatrix();
  BondsMatrix(int count);
  ~BondsMatrix();

  void copy(BondsMatrix* pMatrix) const;
  double GetBond(int idx1, int idx2);
  void SetBond(int idx1, int idx2, double len);
  void Setup(int count);
  bool IsInitialized();
  void Clear();
};


class MathModel
{
public:
  MathModel();
  MathModel(const QString& fileName);
  ~MathModel();
  
  bool loadFromFile(const QString& fileName);

  void solve(AbstractSolver* solver, double tBegin, double tEnd, double tDelta);
  bool solved() const;
  double systemEnergyValue(int idx) const;
  double maxModelRadius(const Point3D& center) const;
  Point3D modelCenter() const;
  Point3D systemMomentumVector(int idx) const;
  void planetCollision(int idx1, int idx2);
  bool getCollisionState();
  void setCollisionState(bool state);
private:
  // TRUE if model have solution (trajectories)
  bool m_solved;
  QString fName;
  bool m_collision;

public:
  QList<PlanetMath> planetSystem;
  BondsMatrix bonds;
  BondsMatrix ropes;
};


#endif // MATH_MODEL_H